﻿using Microsoft.Xrm.Sdk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EWSEditor.CRM
{
    class MailboxAlert
    {
        public DateTime Date { get; set; }
        public int Level { get; set; }
        public string Text { get; set; }
        public string ErrorDetails { get; set; }
        public string TraceActionXML { get; set; }
        public string TraceDetailXML { get; set; }

        public MailboxAlert(Entity alert)
        {
            if (alert.Attributes.Contains("tracedetailxml"))
            {
                TraceDetailXML = (string)alert["tracedetailxml"];
            }

            if (alert.Attributes.Contains("traceactionxml"))
            {
                TraceActionXML = (string)alert["traceactionxml"];
            }

            if (alert.Attributes.Contains("errordetails"))
            {
                ErrorDetails = (string)alert["errordetails"];
            }

            Date = (DateTime)alert["modifiedon"];
            Level = ((OptionSetValue)alert["level"]).Value;

            if (alert.Attributes.Contains("text"))
            {
                Text = (string)alert["text"];
            }
        }


    }
}
